package com.dustedpixels.jasmin.chips.z80.util;

import com.dustedpixels.jasmin.chips.z80.Z80;

/**
 * Compares state of two Z80 chips.
 */
public final class Z80StateComparator {
    /**
     * Return true, if both Z80 chips has equal internal state.
     * 
     * @param z80A The first Z80 chip
     * @param z80B The second Z80 chip
     * @return Comparision result.
     */
    public boolean areStatesEqual(Z80 z80A, Z80 z80B) {
        if (z80A.getAF() != z80B.getAF()) return false;
        if (z80A.getBC() != z80B.getBC()) return false;
        if (z80A.getDE() != z80B.getDE()) return false;
        if (z80A.getHL() != z80B.getHL()) return false;
        if (z80A.getAF2() != z80B.getAF2()) return false;
        if (z80A.getBC2() != z80B.getBC2()) return false;
        if (z80A.getDE2() != z80B.getDE2()) return false;
        if (z80A.getHL2() != z80B.getHL2()) return false;
        if (z80A.getIX() != z80B.getIX()) return false;
        if (z80A.getIY() != z80B.getIY()) return false;
        if (z80A.getSP() != z80B.getSP()) return false;
        if (z80A.getPC() != z80B.getPC()) return false;
        if (z80A.getI() != z80B.getI()) return false;
        if (z80A.getR() != z80B.getR()) return false;
        if (z80A.getIFF1() != z80B.getIFF1()) return false;
        if (z80A.getIFF2() != z80B.getIFF2()) return false;
        if (z80A.getIM() != z80B.getIM()) return false;
        
        return true;
    }
}
